<?php
abstract class Internal_Controller_Action_Tab extends Zend_Controller_Action 
{
    protected $_thisUser = null;
     
    public function init()
    {
        if ($this->_request->isXmlHttpRequest()) {
            $this->_helper->layout->disableLayout();  
        }
        
        if (!$this->_request->isPost()) {
            $get = Zend_Registry::get('getFilter');
            
            if (!isset($get->userId)) {
                throw new Ot_Exception_Input('User ID not set in query string');
            }
            
            $user = new Gdata_Apps_User();
            $this->_thisUser = $user->find($get->userId);
            
            if (is_null($this->_thisUser)) {
                throw new Ot_Exception_Data('User not found');
            }
            
            $this->view->user = $this->_thisUser;
        } else {
            $post = Zend_Registry::get('postFilter');
            
            if (isset($post->userId)) {
                $user = new Gdata_Apps_User();
                $this->_thisUser = $user->find($post->userId);
                
                if (is_null($this->_thisUser)) {
                    throw new Ot_Exception_Data('User not found');
                }
                
                $this->view->user = $this->_thisUser;   
            }
        }
    }
    
    abstract public function indexAction();
}